package com.dime.physical.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.dime.physical.domain.DimeMaincheckhealthadvice;
import com.dime.physical.service.IDimeMaincheckhealthadviceService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 主检健康建议Controller
 * 
 * @author Tiny
 * @date 2023-10-17
 */
@RestController
@RequestMapping("/maincheckhealthadvice")
public class DimeMaincheckhealthadviceController extends BaseController
{
    @Autowired
    private IDimeMaincheckhealthadviceService dimeMaincheckhealthadviceService;

    /**
     * 查询主检健康建议列表
     */
    @RequiresPermissions("physical:maincheckhealthadvice:list")
    @GetMapping("/list")
    public TableDataInfo list(DimeMaincheckhealthadvice dimeMaincheckhealthadvice)
    {
        startPage();
        List<DimeMaincheckhealthadvice> list = dimeMaincheckhealthadviceService.selectDimeMaincheckhealthadviceList(dimeMaincheckhealthadvice);
        return getDataTable(list);
    }

    /**
     * 导出主检健康建议列表
     */
    @RequiresPermissions("physical:maincheckhealthadvice:export")
    @Log(title = "主检健康建议", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, DimeMaincheckhealthadvice dimeMaincheckhealthadvice)
    {
        List<DimeMaincheckhealthadvice> list = dimeMaincheckhealthadviceService.selectDimeMaincheckhealthadviceList(dimeMaincheckhealthadvice);
        ExcelUtil<DimeMaincheckhealthadvice> util = new ExcelUtil<DimeMaincheckhealthadvice>(DimeMaincheckhealthadvice.class);
        util.exportExcel(response, list, "主检健康建议数据");
    }

    /**
     * 获取主检健康建议详细信息
     */
    @RequiresPermissions("physical:maincheckhealthadvice:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return success(dimeMaincheckhealthadviceService.selectDimeMaincheckhealthadviceById(id));
    }

    /**
     * 新增主检健康建议
     */
    @RequiresPermissions("physical:maincheckhealthadvice:add")
    @Log(title = "主检健康建议", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody DimeMaincheckhealthadvice dimeMaincheckhealthadvice)
    {
        return toAjax(dimeMaincheckhealthadviceService.insertDimeMaincheckhealthadvice(dimeMaincheckhealthadvice));
    }

    /**
     * 修改主检健康建议
     */
    @RequiresPermissions("physical:maincheckhealthadvice:edit")
    @Log(title = "主检健康建议", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody DimeMaincheckhealthadvice dimeMaincheckhealthadvice)
    {
        return toAjax(dimeMaincheckhealthadviceService.updateDimeMaincheckhealthadvice(dimeMaincheckhealthadvice));
    }

    /**
     * 删除主检健康建议
     */
    @RequiresPermissions("physical:maincheckhealthadvice:remove")
    @Log(title = "主检健康建议", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(dimeMaincheckhealthadviceService.deleteDimeMaincheckhealthadviceByIds(ids));
    }
}
